// @Desc:
// @CreateTime: 2020/10/26
package utils

import (
    mlog "mycrm.com/log"
    "time"
)

// 获取当天 00:00:00 和 23:59:59
func GetCurDay0And23() (int64, int64) {
    // 获取当前天的 0 点
    curTimeStr := time.Now().Format("2006-01-02")
    mlog.Log.Info("curTime: ", curTimeStr)
    // oneDay := int64(24 * 3600)
    // 使用 Parse 默认获取为UTC时区 需要获取本地时区 所以使用 ParseInLocation
    curTimestamp23, _ := time.ParseInLocation("2006-01-02 15:04:05", curTimeStr+" 23:59:59", time.Local)
    curTimestamp0, _ := time.ParseInLocation("2006-01-02", curTimeStr, time.Local)
    today0 := curTimestamp0.Unix()
    today23 := curTimestamp23.Unix()
    return today0, today23
}

// 是否进行统计
func IsStatisticsVisit() (string, bool) {
    curHour := time.Now().Format("15")
    switch curHour {
    case "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "23": // 不进行更新
        return curHour, false
    default:
        return curHour, true
    }
}
